A computer system often needs to keep track of the pages in a memory that are modified during operation. The memory may be allocated to a guest in a virtual machine system or a user space process. At some point of the operation, another process (a requester) may wish to know which of the pages have been modified. The requester may need to copy the modified pages to another location; for example, to a new location to which the guest allocated with the memory is migrating. To track the modified pages, the computer system keeps a log file to record pointers to the pages that have been modified. Upon request, the log file is passed to the requester.
To ensure write accesses to the pages are accurately tracked, a conventional computer system typically locks the memory upon receipt of the request for the log file. The lock prevents memory pages from being made writable by any guest or process, blocking the guest or process if it requests this access. In particular, if a memory page is write-protected for write-tracking purposes, locking suspends guest/process write access to this memory and, therefore, degrades system performance. However, without using a lock, the computer system may fail to capture a write access during the time the system is prepared for a new round of write tracking.